package utils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Tools {
	
	public static long startTime;
	
	public enum OutputType {
		DEBUG,
		STATISTIC,
		REDUNDANCE,
		MARK_START,
		MARK_END,
		RESULT
	}
	
	public static void output(String data, OutputType type) {
		String[] datas = data.split(System.lineSeparator());
		String mark = "[?]";
		switch (type) {
		case DEBUG:
			mark = "DEBUG";
			break;
		case STATISTIC:
			mark = "STATISTIC";
			break;
		case REDUNDANCE:
			mark = "REDUNDANCE";
			break;
		case MARK_START:
			mark = "START";
			break;
		case MARK_END:
			mark = "END";
			break;
		case RESULT:
			mark = "RESULT";
			break;
		default:
			break;
		}
		
		for (String d : datas) {
//			d = String.format("[%d:%s:%s]", ManagementFactory.getRuntimeMXBean().getUptime(), mark, d);
			d = String.format("<%s:%s>", mark, d);
			System.out.println(d);
		}
		
	}
	
	public static void toFile(String data, String fileName) {
		File file = new File(fileName);
		try {
			if (!file.exists()) {
				file.createNewFile();
			}
			
			FileWriter fw = new FileWriter(file.getName(), true);
			BufferedWriter bw = new BufferedWriter(fw);
			bw.write(data);
			bw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}
	
	
	public static long[] newMem(long size) {
		long[] mem = new long[(int) size];
		for (int i = 0; i < size; i++) {
			mem[i] = i;
		}
		return mem;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
	}


}
